class ProductsController < ApplicationController

  def find_all
    render :amf => Product.find(:all)
  end

  # expect single argument: product id
  def find_by_id
    render :amf => Product.find(params[:id])
  end

  # saves new and updates existing Products
  # expect params[0] to be incoming Product
  def save
    @product = params[0]

    if @product.save
      render :amf => @product
    else
      render :amf => FaultObject.new(@product.errors.full_messages.join('\n'))
    end
  end

  # expect single argument: product id
  def destroy
    @product = Product.find(params[:id])
    @product.destroy

    render :amf => true
  end
end
